package com.ruoyi.project.blog.controller;

import com.ruoyi.common.utils.bean.ResponseResult;
import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
import com.ruoyi.project.blog.service.IBCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author blue
 * @date 2022/1/13
 * @apiNote
 */
@RestController
@RequestMapping("/collect")
@RequiredArgsConstructor
@Api(tags = "文章收藏API-V1")
public class BCollectController {

    private final IBCollectService collectService;

    @GetMapping(value = "/")
    @ApiOperation(value = "我的收藏列表", httpMethod = "GET", response = ResponseResult.class, notes = "我的收藏列表")
    public ResponseResult selectCollectList() {
        return collectService.selectCollectList();
    }

    @Anonymous
    @GetMapping(value = "collect")
    @ApiOperation(value = "收藏文章", httpMethod = "GET", response = ResponseResult.class, notes = "收藏文章")
    public ResponseResult collect(Long articleId) {
        return collectService.collect(articleId);
    }

    @DeleteMapping(value = "/")
    @ApiOperation(value = "取消收藏", httpMethod = "DELETE", response = ResponseResult.class, notes = "取消收藏")
    public ResponseResult cancel(Long articleId) {
        return collectService.cancel(articleId);
    }
}
